package com.ssh.demo.action;

import java.io.IOException;
import java.io.Serializable;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.ssh.demo.dao.entity.User;
import com.ssh.demo.service.UserService;


public class UserServlet extends HttpServlet {

	@Autowired
	private UserService userService;
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1262480384896212320L;

	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		// TODO Auto-generated method stub
		super.doGet(req, resp);
	}

	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		req.getParameterMap();
		String name = req.getParameter("name");
		String age = req.getParameter("age");
		String sex = req.getParameter("sex");
		User user = new User();
		user.setName(name);
		user.setSex(sex);
		Serializable id = userService.save(user);
		System.out.println(id);
	}

	
	
	
}
